refactor tabledef io structures and api