Tidied up dependency-handling logic.
Added direct reference handling to parse_requirement.