fixes for key not found and null reference exceptions

Yea, I saw that a couple of weeks ago as well, but just never got around to fixing it. Glad someone opened up and issue and forced me to fix it.