Factor controller-related code in its own mod