Fix dump and restore on memory limited systems