Added new template resolving logic.