Fixed a few issues revealed after testing on a linux box.