Various commenting and refactoring