fixed a bug where we were failing to detach entities being based to a
separate entity manager.
improved comments.