js: polished out some bugs