Fixes issues on how objects are attached and detached from the datacontext during object lifecycles.