Clean up debug logging with ... logging
Add logfile and daemon options
Retry asking for the password if opening the database fails
Add timeout-based on-demand password prompting