cleanup buffer
fix deadlock
fix deadlock