Some code refactoring.