Refactored storage to use typeclasses