More comments / docs
Add in-place versions of maths functions to protocol
Tidy code
Doc edits