[RCD] Patches for trac 1486782 and for priority sort