misc
fixed many problems pointed out by jshint