Fix bugs which let to wrong results in 25% of all cases.