Fix the bug/exception when there are subject that don't provide anything.

Remove modification of #provides in buildEdges and refactor the method a bit.