Fixes to promises code