Added some additional logging
Fixed setImmediate call