Make key handling more typesafe

The code was correct before, but this is more idiomatic.
Merge pull request #14 from pythonesque/master

Make key handling more typesafe