bunch of refactoring changes