Bug and typo fixing