Fixes #3479: Make it possible to use AM 1.13 on v1.6 branch

Custom patch on ticket, based on r27909.