Refactoring and cleanup
Refactoring and cleanup 2