Tweak to prevent NoneType error.
Changed how type is checked to be compatible with Python 2.6. "isinstance" checks if an object is of a class or any subclass (e.g., dict or OrderedDict).