tpl refactoring, cache code cleanup
tpl refactoring and bugfixes