Various code cleanups