Some minor code refactoring.