updated handling of NAs. Now there is a global NA value for the whole vec.