remove unused code
categories sort desc by count

* and fix a bug