Improved performance of Definition

1) Improved finding locked_deps efficiency in coverage_local_specs
   from O(N^2) to O(N).
2) Improved specs_changed from O(N^2) to O(N)