Fix JS bugs