Fixed a bug for sizes that are not a multiple of block size