Correct content type and tidy up xml