Fix stack overflow on page reload in IE