Documentation and comments.

Also moved callback set/unset interface to end of file, to facilitate
bottom up reading.