Merged with sam's version

xml and json supported

core function pulled out