Fixed math.random range bug (1,1 is a valid range now.)
Fixed function definition code generation to work in more cases.