Refactor deserialize packet.