Allow widgets to be constructed from Javascript

Also fixes a bug in the comm manager.