Added XML repair functionality to fix #14