Generally the templates need to be added in a specific order so that these errors do not show up.
Maybe you could review the order and 'include' them in sequence within your Main file.