Added a more intelligent hit assignment algorithm.