Attach and Detach commands

Based on contributions in #46