Refactor callbacks using `setImmediate`
Minor refactor
Added linting