Fixed bug in build graph algorithm, fixed patsubst