Fixing bug #8 by checking for a possible null flag value.