Reworked promises to use new API immediate to execute functions as soon as possible.