Some improvements to the agenda-sorting