Many changes relating to sorting of backend.
DB simplifications.