fixes very slow generation of large files