Fixed: re-implemented JS optimizations