Factor out mapping over dependencies...

will be used to track build dependencies too, shortly