Linux Compatibility

Ok, lots of changes to make this run on Linux. These are UGLY, lots of
defines, i was in a hurry to make it work.