You're encouraged to use the sockmark and $sock().mark instead of setting global variables here and there, then having them unset at the end.
Using /sockmark puts the data in a temporary storage for later reference with $sock().mark, and the storage space is eliminated by itself after socket has finished its required task.