David Volgyes' changes plus things I noticed while reviewing them

I've rebased David's work and made some changes of my own to code I noticed while reviewing his changes.
I've (finally) built and tested; nothing breaks that wasn't broken before !