Finalised the attach/detach state transitions