Refactor with-server macro and change how database is specified.