Minor refactoring to clean u the code.