Fix set collection view layout bugs

Hi,

PullReq sent earlier has several bugs. So, I have to fix it.