Switched to stable sorting of commands and adjusted priorities.