Fixed bugs in clear categories after switch to array