Clear Js code

Huge improvement of coding structure