Placed control-panel specific actions into function.

Global-scope function calls were happening on EVERY page refresh.
Caused templates at swu to get spammed.