Several compatibility and bugfixes