added preliminary demuxing code
fiddled with chunking