Update regexes and error handing
more fine-tuned template placement