Fixed problem with to general classes. TODO: adapt threshold computation.