Fix bug in classification, add ordering to entity relationship query.