A lot of bug fixes