more massive refactor, all tests work again...
i'm going to nuke a lot of this code, so checkpoint it here