Merged in fix for scope issue with gridfs