Add templated flag handling.