Fixed error when building category tree
Work on progress...