Rewrote mainform from scratch.