Improved processCommand, and processPacket