Intergrated TemplateManager's code into kite.py
I don't know whether or not I should leave the comments in but I have for the time being.