fixup main table creation and updates
sorting implemented for first and second-level objects