minor cleanups and optimizations