add Template class and begin to improve template support