Fixed a minor bug and cleaned up a bit.