Fixed build on OSX and with Top-of-Trunk LLVM

Hi, I've found these changes make it build and work correctly on OSX using clang's libc++ and also something changed in ToT llvm that required an additional explicit header inclusion.

Would you consider for merging?