Changes to support compiling on OSX

Mainly header reorders and removal of duplicate typedefs.