now with code fixes so it actually compiles

should be complete, but is untested (worked 2 commits back)