Moved port_select function to bottom
Use native caching system
Use own cache policy

This checks modification dates of the repository database and completion cache
and refreshes the latter if it is older than the database.