fixes to file streaming and speedup