Improve optimized size calculation