Rework template and code a bit. Using g instead of _app_ctx now.