WIP: major refactor