Fix a couple of JS bugs