A number of bug fixes