minor variable renaming and correct flag -> bool conversion.