Refactor to use separate model and database client.