some tweaks and fixes to d417f7b and 3dcbbc2
Merge pull request #3179 from xabbuh/master-tweaks

some tweaks and fixes to d417f7b and 3dcbbc2