Optimize removal of inactive packages