Merge series from Richard Fitzgerald <rf@opensource.cirrus.com>: Various code improvements. These remove redundant code and clean up less-than-optimal original implementations.