continued refactor, currently in a broken state...