Eliminate dependency between topology and resources. Fix bug.