Dependency checking code HEAVILY optimised.