More sqlite migration

Migrates all remaining commands to sqlite with the exception of mystats
and API calls. Adds a pastnames table to simplify name-related queries.