Using the results of the vulnerability scan at lgtm.com, some minor changes were made. First, all Python exception handling now explicitly catches Exception, rather than BaseException (which would include SystemExit and KeyboardInterrupt). Second, unused imports were removed. Third, a couple of unnecessary or unused assignments were addressed. Finally, the JavaScript was modified to explicitly declare the local ddiv variable when needed.