Fixed namespace issues during writing