Fixed most compilation errors