various changes for code review from @caryp