Refactored out the main storage code into its own abstract class.