bug fixes in Javascript reset function and other fixes