Add some limits for b, and let searching shape align to meanShape before computing b.