Patched templates + code for 3.1 support