Bug: Do not rely on obj.__cmp__() in data manager.

Objects where compared within the transaction manager for different
reasons. This could create complicated scenarios (including data loss) when
the ``__cmp__()`` method of the object was non-trivial. Now the result of
the ``id(obj)`` function is used to compare objects, which is very save,
since the behavior of this function call cannot be changed for an object.
Code cleanup
Track object ids instead of objects themselves

in operator on objects may have unexpected side-effects, like
calling __cmp__() on objects.