IE11 support

This is mainly just a backport of the 1.8 changes for IE11 support.