Fixed type overchecking in recursive_replace