Split collision code into two parts, detection and resolution. Lots of other fixes as well. Adding in friction.