Problem with nested templates