As a more complex but (at least arguably) better refactoring, I would suggest getting rid of the $messageStack object creation in includes/init_includes/init_zca_bootstrap.php and simply loading the correct class in the includes/auto_loaders/config.core.php based on the setting of the template.