Fixing optimization with new spatial reference.