added attach/detach for garbage collection stuff