Various refactoring and doxygen formatting