Initial commit.

Simulation is nearly functional but needs testing.