Fixed a major bug in chunk handling.