Revamped code architecture.

Moved much of the data to the MapState singleton