first round of bug fixes