abstracting database connection logic and adding a daemon to kill old sessions