Fixed compilation errors
Fixed surface handling