various cleanups and minor fixes