Small cleanups and documentation

Doxygen comments for some functions added.