Did some code refactoring.