several js bugs fixed