Sanitize inputs and updating entry location

I also moved the scoping of the variables at the top of the js file to only be scoped within the closure instead of being globally scoped as that could potentially cause issues with other extensions.