Toward immutable data structures

The main datastructures are now immutables. Some additional work might be useful in the future, but low priority.

Note that Ant build is broken.