cleans up the javascript a bit while hooking up the overlays.