Commented and cleaned up a bit.