added api access, fixed bug with category counting