Fix bugs with promises.