Do not eliminate variables only occurring in patterns.  Minor improvements to sort inference.  Remove unused code.