Very minor point, but shouldn't you be catching KeyError here?  We should be getting out of the habit of [Pokemon Exception Catching](http://www.codinghorror.com/blog/2012/07/new-programming-jargon.html) in the code.