Added a check to test for duplicate module names.

Got a weird nasty NPE because I didn't have this check.