Code fixes and improvements. No new functionality added.