Fix & refactor.

Don't start the app until the database is opened.

Switch to SHA512 from MD5.