Partial rewrite to allow multiple windows.

Smaller than I thought, but it sufficient to allow multiple windows while maintaining previous functionality.

File format has changed a good deal.