Tidied up the Packet Handler.

Switch is much cleaner than ifelse