Changed simplification code to properly compare nodes