Fix issue #755

I'm sorry for all those merge commits. I tried following [this answer](http://stackoverflow.com/questions/16358418/how-to-avoid-merge-commit-hell-on-github-bitbucket), but they still got into this PR.

It should be possible to cherry pick the right two commits, though.