Added support for file/chunk buffering, not finished