Fix detaching

Now it’s possible to attach again after detach