Some formatting and removal of redundant code.
Most protocol-commands implemented, but only basic