some clean up and lots of documentation

Syntax is doxygen