Cleaned up datastore usage.

Modified datastore usage with read/write buffers instead of direct access to current working directory. Reduced use of local filesystem for normal operations. Moved all local filesystem writes to safer temporary directories.