TSObject serdes; twisted code refactoring