So you want to clean up if the tx exists when setup() was first called, but not if it's opened later? I believe that's what will happen here and it sounds different from what the comment at L103 says.