Fix dependency cycle bug