Fixed datamodel so it now properly uses UTF-8 when writitng to files and so that it will properly write exceptions.