Refactoring and cleanup
Refactoring and cleaning up 2