Fix most compile errors, there are still some failing tests.