Reworked dependency inheritance, fixes #365
Polish
Merge pull request #492 from lev-kuznetsov/master

Fixes #365