Performed some minor refactoring and code cleanup.