Bug fixed, and some changes to facilitate bughunting.