Reimplement dependency order handling to solve a performance issue.