Storage fixes for edge cases

Fixes #363, fixes #362