There's a duplication of active menu items when using custom post types. Namely that custom posts nested beneath a page cause the blog to become `.active` while simultaneously setting the parent page `.active` and the current menu item `.active`. This patch fixes all that nonsense. If you `print_r($classes); print_r($new_classes)` on line 60 you'll see that there are always at least 2 active replaces prior to the `array_unique($new_classes)`. The `array_search('current-menu-item',...` conditional check is to ensure that `.active` is still set for current menu item regardless of the number of `$new_class_counts`.