Backports to v0.4.x (#517) until 0640376e68a3947f0c2b82e877bdce9fa2735169

Backport (#517) everything useful until 0640376e68a3947f0c2b82e877bdce9fa2735169

Travis for individual commits are in my fork. I will run partests as soon as I get to the office.