Factor out initialization which requires database connection.