Refactor network code into PacketReader class