Various bug and typo corrections.