Fixes a bug in restore (only on debug)