Fixes to widget JavaScript