Factor out mode-specific variables