clean up engine's code formatting
redesign return values in bbox_sort, adjust code in insert