Fixed issues where a promise whas expected but undefined was provided