More fixes

Several more fixes for platform compatibility.  With this it should mostly work on FreeBSD.  For some reason execvP() doesn't want to work on FreeBSD and I'm really not sure why yet.

The open flags bit is probably a bit more important.  I noticed the lack of O_TRUNC quite a bit while testing.