Merged bugfixes from main branch