Fix compilation bugs, still a bunch of stuff left to do