Refactoring of mindjailengine.py