Take the ref after setting the caps on a buffer because else the buffer is techinically not writable.