Updated to sync ajax

Made the ajax loading of templates synchronous to avoid issues with
loops.