Comment 69 for bug 294712

Created an attachment (id=383869)
WIP

This seems to work fine in my tests locally, gonna hook up automatic tests next. Comments, as always, welcome :) .