Backport HABTM from 4-1