Unification of ctx and ctx->ui checks.