Bug fixes, and comments compatible with doxygen