Made buffer functions atomic.