Fixed performance problems with the water grid. The debug version of vector performs range checking, which really slowed down updates since operator[] was being called hundreds of thousands of times a second.

Also fixed another bug where the program was asserting on exit. I wasn't being careful with pointer ownership on the main window, and it was being deleted more than once. Since ownership life is indeterminate, storage of the main window pointer is being done with a smart_ptr.