refactor (wip); now compiles