remove dead code, fix Mac OSX build, fix includes