partial refactor of fork_db... more work later