js: Some code improvements.