WIP. Nearly done, renaming/typechecking ok, just mopping up