cleanup and fix in buffer behaviour