More bugfixes from PR comments