Check for nil when doing equality testing and make sure not to insert nil into the dictionary.