Templates

Mostly small changes and stability fixes.