Improve memory usage.
Update js tests.