Trying to clean up db handles. Still a bit wonky.