fixed the infinite loop in iterator() and getTemplates() (facepalm)