Fixed a few bugs in simplification