Various fixes to get it stuff to compile with g++