Don't scope timer functions to window object.

This was broken in nodejs as the timer functions are defined on the `global` object. We need to check whether `global` or `window` is defined and roll with that.