Fixes some of the code issues reported by #155
(In hindsight I probably should have based this on master, considering some of them are definitely compiling related ...but I based the branch on next so, there we are)
master
next