remove function get_templates, and general tidyup