Refactoring for speed.

I took away the defensive if-statement and replaced it with a try/catch
instead. The resulting speed up is massive. It took about 50 seconds to
process 1000 keys. Now it takes about 1.5 seconds to process 100 000 keys.

You do the math.