Moved variable 'type' declaration to outer function scope.

Doing this against my conviction in order to settle #980. Would much
prefer to move variables to the inner-most scope instead.
Merge pull request #980 from cederberg/patch-1

Moved variable 'el' declaration into inner scope