new implementation, with one master buffer, plus tests