formatting, get rid of unused code, also prune buffers when idle