Thumper's OSX fixes

Thumper made some changes to allow compilation with clang on OSX. I've verified that the changes don't conflict with other platforms.