Add setTimeout replacement and move unrelated functions to utilities.js