Adding protection against template flickering