Fixed little bugs in the template class