Broken paths on taxonomies after changing permalink to post name

I added a rewrite rule manually.

  add_rewrite_rule('^bar([^/]+)(/[0-9]+)?/?$','index.php?bar=$matches[1]','top');

right after

add_action('init', 'register_taxonomy_bar');

in functions.php.

But WordPress is SERIOUSLY DENSE in translating /bar/foo/ to barfoo?bar=foo and I don’t know how to get around this nonsensical “barfoo” in the path. I also have no idea what it’ll do to paging. Also this has to be defined for each and every custom taxonomy.

Nevertheless, it works, sort of.