Start reworking the protocol encoder/decoder into something sensible.

We are replacing a large complicated protocol encoder/decoder with a simple 10 line encoder/decoder now :)
Make the wire protocol internally consistent thanks to Erlang QuickCheck.