Javascript: improvements