Some of the code refactoring.