Cleanup, Refactoring and other improvements