collapse small classes into one class