Add generic version of attach_*()
Add generic version for detach_*()