Fix partial-buffer problem