Fixed spurious events when removing layers that are not fully loaded