Initial commit for protocol version 3 update. Needs further testing and improvement