Performed a few refactorings for readability.