Prune code - add logging.
Update comments, slight refactor.
Add methods for counting table rows.