Copy some implementation of sink facility from cycamore.