Improved template class