[TS] Moved data handling to their own funcs.