Defect adding function fixed + some small fixeds and old useless code removal + added missing table to DB