TANAL-65: try and clear locals in loop when possible