wip: unfinished, untested rewrite