IE8 Compatibility

as well as some small efficiency improvements