Rewrote portions that were not making sense.