lots of refactoring and architectural changes