Fix several promise-related issues