OSX Compilation

@damiller and @pcbend both suggested many modifications to get things to compile on OSX - many problems were solved, but compilation is still not quite happening; need to check if nothing broke in linux.