Bug fixing.

Just lots of small edits.