Added ability to specify an external database connection.