Applied @lohmander's fix for IE8 memory bug.

Manually applied @lohmander's patch from PR #25, which fixes the IE8 memory bug for me as well. Throwing in a PR so that this can potentially get merged in to master.