Fix buggy promise implementation.