Reworked dependency inheritance, fixes #365