(Issue #3809) clean up code