Uninstall dependencies in the right order.

This should fix #491