Added more js code doc and renamed some variables