TRUNK-3586 Slightly improved and prepared for backporting