fixed truly ugly integer overflow bug, which only showed up in the compiled javascript version