More optimizations and IE8 compatibility