More refactoring and getting started on encounters.