fix 'partial writes' handling