Solution? Don't violate the law. Don't get thrown in prison. I know a real good guy who went to prison for the lies of his wife. He didn't deserve it. He also didn't deserve to get raped and killed there. He violaed no laws, but was convicted by a scumbag DA on the lies of his wife.
I will second that. A good friend of mine just finished a divorce and his ex lied through her miserable teeth about him assaulting her. Made it up. But, the cops came and he was charged with a felony. Lucky for him the case fell apart and he did not have to do jail time.
But, as B-chan suggests, it can happen to the innocent.