Refactored plugins into Scaffold controller

Refactored code of the plugins Detach and Attach into the Scaffold
controller.