performance tweaks

Switched to postMessage and animationFrame for script yielding