do cleanups and speed improvments, especially in get_templates.
get_templates() now separated into get_templates_all() and get_template().