some refactors at tg codebase