Smarter viewport/viewbox management; code cleanup

Also added a feature to fit all illustration contents into view;
improved syncing of scrollbars and viewport; and general improvements to
code and layout.