Now algorithm can handle box size <20

It apparently has some issues, so need to be debugged.
commit