Fix possible DOS and small changes to timeouts

By sending many upgrade event a client could possible create a lot of intervals without the old ones having a chance of being cleared. I also added the intervals to the constructor and made it use setImmediate instead of process.nextTick.