Vuln fix misc 3

This Pr include a number of miscellaneous bug fixes based on the GEM Vulnerability Database & GUI Google document.  
what is the difference between ```if ((o+2)%2==0) {``` and the more simple  ```if (o%2 == 0) {``` ?