Robustness improvements and JSHint fixes