HTML5 syntax error changed max"4" to max="4"
Code cleanup - function order and JSLint quality changes