More clean up and refactoring