A series of bug fixes