Removed unused function.
Added logic for saving the templates file.
Added support for templates.
Changed type of 'attachedTemplates' variable.
Corrected replacement of quotes and apostrophes in selector expressions.