Imported StorageFormat 5 changes from Martin's tree.