Fixed an error in math.typeof on Internet Explorer.
Minor tweaks in code and comments