Cleaned up module generation code.