Fixed a bug in the block-collapsing optimization