Fixed compilation errors in generated code, and fixed PerCustomResultTemplate constructor. refs #476