Convert on_enter, on_exit and refresh_i18n to use promises and add maybe_promise for state handlers.