Adding require and cleaning up the js mess