Trying to extract out game logic from GUI.
WARNING: many things changed and lots of dead code / comments