Fix security issue that allowed recovery of the original navigator object.
Reorganized scripts and added comments for easier readability and maintenance.