I think that we could just as well replace this with `return new Promise(function (resolve) {` (and of course with some adjustments in the code below), but I wasn't sure if that kind of change was really desirable w.r.t. readability of the code.