changed: counting fields on heap instead of stack (would quickly cause
overflow on higher levels)