Prevent crashes through improved promise handling, report more errors to the user, code cleanup