Xmf cleanup, misc fixes