Complete madecom.py; modify database handling