Updated xml writer to include debug option