Fixed promise rejection handling.