Unnecessary code cleanups

Removes unused code, code that can be derived automatically, and code that can be written in a more general way.