Fixes to correctly use a promise