Refactoring of promises impl.