Backports 0.6.x to 0.5.x

Backports everything until e88b9cefad72961c464fe5a58b0a07527c1e360f