weird hacks to fix compilation errors with mac os 10.8

I really don't get why these are needed, for some reason the compiler seems to be adding extra consts to this in various places.