Many bugfixes