Dozens of bug fixes