New rule to check for undeclared dependencies and a bit of refactoring