Fixed Bug #478

Avoid clearing references on BaseObject in __sleep method
because this breaks setting foreign references. By cloning the
BaseObject itself we ensure the the Baseobject itself is not
changing but sleep still returning the same