Merged buffer size handling & threading fix from Ville Heikkinen.