Code fix, implementation of fading speed setting

What about some code style improvement? I removed double code, fixed variable definition without "var", fixed unclear variable (and function) names. I also added possibility of fading speed setting. I didn't change code formatting style.
Or I don't know something and it all is for compatibility?