Use consistent variable names and pointer borrowing in Javascript implementations