Added proper protocol versioning and ironed out a few oddities in the
initial handshake.