misc improvements

see commit comments for details