Organize and comment js, get rid of useless code