Remove unused code.
Move to buf id to buf mapping. Kill more unused code.