Added unloading flag to prevent recursive calls from blowing the stack. Removed unnecessary existence check in getDependencies.