partial rewrite, wip (doesn't update to factory)