Fixes for edge-case JavaScript errors.