Cleanup. Remove uneeded template elements and other fixes.