Further commenting and refactoring.