Some modularization
Make JSLint somewhat more happy