fixes after Marcin's code review
added singleton pattern template class