Finished rewrite of the protocol