Optimized clearBuffer