If there’s a problem with changing the prefix then I’d look elsewhere, maybe in another plugin is causing it or the theme? It would seem that something would actually need to be saving the prefix, or assuming that the prefix is wp_ instead of using $wpdb->prefix.