Clean up the filestorage package.

This cleanup makes a subsequent patch much simpler.  The changes here are intended to be entirely backward-compatible, if not idempotent.  It mostly involves just moving code around.