Use single quotes for JavaScript string literals.

Mainly for consistency, as they seem to be the dominant style.
Remove unused ids.
Prevent "undefined" from being serialized.
Factor out computing checked for readability.