Enhanced template class mapping so it can deal with multiple classes