Added order by class in export_txt.
Optimizations in update queries.