Lot of bugfixes