Duplicate kwargs hash before assignment logic. Fixes ##1403.

Note that this implementation is much more costly than it should
be since it mutates the hash while it assigns variables. The new
duping makes it even more costly, but avoids the damage it caused
to the incoming hash.