Butchered dependency algorithm... will fix
Further butchered dependency algorithm... will fix more