Bugfixes when handling replacement blocks