Fix division by zero bug in corner detectors

Finally fixes issue #471.