Trying to get OT to compile and work on Mac OS Mavericks

Lots of small build changes, cleaned up heaps.
These changes should be somewhat transparent to Linux and other build systems.