Avoid detach() call on undefined instances