Initial work on improving heuristics for attachment/detachment, see #207 #176 #194