js: simplify counter updating, remove some unused stuff
js: remove several commented out functions