reorder tables, fix switch leave bug