Generic shrink evaluation.

I found bugs in past implementations, and believe to have found a
correct one.

Read the diff for more information.