Initial version, moved a lot of stuff from the war-worlds.com code.