Improved dependencies.py performance

Made a few changes to make dependencies.py a little faster