Extracted structure identification
Optimized .size() calls out of loops