C4::Auth::get_template_and_user is a terrifyingly large function that does way too many things, and it's a complete mess. Many of the $template->param interactions are just setting system preferences. We shouldn't even need to do that anymore.
I don't think we're going to ever fix it, so I think the only real hope is to eventually replace it via Bug 26791 or equivalent.