Rectified bugs in simplify.py