Merge back missed commit and fix compilation errors

Looks like commit:dc7e44ec99aaf1737c448695fc74c21b0e71fe34 was dropped with  some 'git push -f master'