Refactored networking.py and added a PacketHandler