Fix crash-on-second-load bug