Fix saveFlag/saveFlagN giving wrong result