many js bugs solved

and still many to do.