Modified buffer clearing

Still need to modify android to use the new function