Minor style fix
Refactor resizing code

Still far from proper API but less evil than before.
Refactor widget toggling

Thus still needs lots of improvement, e.g. by substituting
some of the jquery dom-parsing-and-inserting-and-then-fiddling-out-again
with vanilla js.