Change to store template ID and not path; also bug fixes and fine-tuning the detectio...