Backport bufixes from next to master

This backports the following PRs to master:
* #1052
* #1042
* #1045
* #1048
* #1050