Fix for NaN in very sharp corners