Fixing credential caching issue when using GridFS
Making authentication as a inline deferred.
Fixing issues with GridFS read and write.