lots of refactoring in prep. for last implementations