Fix memleak and assignment for cached lengths in corrector