Speed improvements by rewriting the step removing \0 from javascript to java