refactoring and cleaning up recent branch rebase