Clean up source code; Fix syntax errors; Make Linter happy

Shouldn't break anything.

* fixed a few syntax errors (double var etc.)
* made JSHint much happier (added semicolons etc.)