Cherry-pick bug fixes from release-0.13

Suggested reviewer: @iliastsi