Lots of bug fixes, compiles now