Cleanup database and add indexes.

Trying to speed up the database of installed packages, by adding
indexes and moving big data from the packages table into an extra
dependencies table.