porting and cleaning up storage functions