[PATCH 2/9] conf: Move mode detection into helper function