#103 rebased

@samalba I borked the rebase in #103 somehow.

This is a new branch with the same hand-picked commits, fresh on top of master.

Sorry for the noise...