Fixed some issues with promises