Use the dict.get method instead of checking for existence of keys.
General cleanup.