Clean the code, add category tree features