Avoid memory issues when outputting large files
Add debug info function