lots of refactoring and shifting stuff around