Fix horrible bugs, get it compiling