HOPKINS: Added a more comprehensive rects merge code