Minor template and logic fixes