SORT CASES: Improve error messages and coding style.