Fixed serializing templates