Added changes/fixes for Linux, possibly broke for Macs.