Reorganized extraction.py and some other modifications