Fix loading of objects that can't be loaded.

If an object can't be loaded, the code now correctly reports the error,
tears down structures that were created, and removes the object again,
making it leave the selection if it was in it. The previous solution
sort of worked, but relied very much on precise timings of things,
while this should work no matter what order the invocation events come
in.
Fixed bug that made it impossible to remove items from the selection if the selection is items.

Honestly, how did this ever work to begin with?
Fixed various issues, including previous fixes.