added xqreader for mg and made some minor changes