Fixing a crash on nil keys

Adding a check to not add an object to a dictionary if the primary key is nil