Did a lot of body segment logic.

I works quite well, but it could still be improved.  I also need to do a
few other things with it.  Also, I fixed a few bugs.