libstdc++ compatibility fixes

Fixes #1 mostly. Document validity checking is not quite right making 2 of the BSON tests fail.