Fix deque changes while looping
Fix various disk buffer issues