Make the removePath function atomic and faster.
Avoid writing hasCapturePaths if there's no need.