Small refactoring and clean up