Ported dependency package trimming from the previous version. Need to clean it up and implement the conflict package trimming.