Improved PacketStructure

To avoid creating a function on each new instance, and moved functions
inside loops, outside.

You might want to try and test if there is nothing breaking. Over 200 packets were changed.