Fix high mem usage on restore