Cleanup some code with promises.