MAJOR BUG: setImmediate used incorrectly.