Bugfix: Account for rules sorted after unmanaged rules

The offset calculation assumed rules numbered 9000+ would be sorted to
the end and didn't need to be accounted for. Turns out some people like
to use really high rule numbers. This should fix that