updated widget code (changes brought over from gh-pages branch)