Is this an error? If not, it may be better to move the buffer reset below this?