More cleanups

More small adjustments to various pieces of code. Reduces the total number of lines of code as a nice side effect.