Template class and t extension bug fixes