Outsourced to extension methods, fixed template bug