Added comments and styling to refactored code.