A bit of code cleanup and updates for promise a+ compliance