Fix count method
Tidy up stuff I can't remember.