Fix some sorting and priority issues.