Lots of refactoring for the sending and receiving of xml functions.
More refactoring, moved the xnl functions into a separate file.