Formatted text, removed not used variables, fixed leaking variables to global scope.