Merge pull request #1219 from gzm0/backports

Backports 0.6.x to 0.5.x