tpl yf: several optimizations
code cleanup