Well loop.js was originally made for the worker thread :D !

Anyway, it is fairly generic, but I guess it might be better to take the approach of making functions global later rather than sooner, to prevent such helper function bloat as we had before.