Even more refactoring, commenting and renaming.