Fix manager so that dependencies only get uninstalled AFTER it is sure the dependant is uninstalled. Fixes foreign key constraint errors.