work in progress. trying to get sensible buffer managment.