merged 'remove' and 'detach' methods