A bag of fixes for clang errors

Should fix a number of bugs in clang++