Reworked code for generation of module and __init__.py files