fixed a problem in GetDat(), minor other edits