break out all the things to functions, move stuff to repl.cc and get rid of ldb:: on everything