Fix compilation errors and warnings