Fix most compilation errors