Some minor bug fixes and tuning.