A lot of bugfixes