Make code more robust.
Add chunk and iconv interface