Added tally field, refactored

- Renamed/refactored functions
- Updated tests