Implement counterCache for Reference and TextBook model.

Also updates bugs in add and edit of both models.