cleanup and portability upgrades
Merge remote-tracking branch 'origin/master'