Several build changes and a couple cpp mods to get it compiling under Ubuntu