a lot of buf fixes