Fix #180 and #1059 by checking for duplicate module names