Resolve JSHint warnings "Missing semicolon", "Don't make functions within a loop"