Refactored storage code generation