Improved autoloading of entries in catalogs.

Previously an infinite loop could occur. Also some exceptions about
template not being in the DOM was sometimes shown in the console.