big refactor wip