Move path clearning inside begin/ensure block