Avoid stack overflow when checking dependencies

Issue #53