+ almost complete rewrite, still not runnable, but almost