Workaround IE9 insertBefore bug. Fixes #1566.