Fix use of deprecated context functions.

Also, improve import to use new qformat_xml method.