Fix dependency generation (might help #407)
Merge review 252 by @tryneus (#407)