minor code improvements and style cleanups