I, How did the court appearance go? You've pretty much summed it up...the lies, lashing out, etc. are purely projection on to you how he feels about himself and also, the things he does. If you can walk away from him when he's like this, do so. You are a human being w/feelings and you've done nothing to deserve this verbal abuse. The less you react, the better.
Please take care of yourself.
Sit quietly, the answers will reveal themselves when you least expect them to. The past is gone, the present is a gift and you need to focus on today, allow the future to reveal itself when it is ready.