Issue #2329773 by amagdy, Mark Trapp: Clean up variables when no longer in use