Correctly respect reader and writer index