global code, comments and API cleanup

Removing useless const, replacing & with * or implicit-sharing copies,
etc.