This is in some sense a successor to id:cover.1411914914.git.jani at nikula.org It includes the first two patches of that series verbatim, and adds some tests.