Assorted portability fixes
Includes lots of stuff to deal with the ancient version of Ubuntu that
Travis uses.