Fix Javascript errors