Refactored packet_parser code