Backport #674 to 0.11 branch

10845a747904cf2a6ddefbf9b6c07e1d769238c2 fixes a lot of bugs and shouldn't be too hard to apply to the 0.11.1 tag.

Context: https://twitter.com/grhmc/status/368080768649547777

Ref #674