simpler impl of backdoor.py and few minor changes