Remove some now-unused code.
Fix a wrong type constraint.
Some more small optimizations.