Clean js code, remove unused functions and variable, renamed, add
commentary