Made buffer clearing optional