Build fixes

Some minor fixes that cut down warnings and probably improve portability and interoperability.