Bugfixes from latest commits