Add support for attach api, this is copied from #33