Lot of bug fixes