Big changes. This is more or less the final revision.
Oops. Updated.