Fix/namespacing

This has the latest changes from the facebook master branch
As well as old changes to support building with dmd 2.065.