Support for v2 of the protocol

All of v2 support in one big chunk.