add dtach functions and fix compl fold