Initial version
Removed common logic, placed in protocol.js
Changes due to new protocol.js