Correctness fixes to PC scripts.
Fix some BSD incompatibilities.