split twt struct related functions into new file