Many many bugfixes