Fix order of buffer operations