General cleanups, and started OSX and FreeBSD porting for kicks