Fixed the attach/detach on first attachment