Inverse fix, rule sort fix, output fix