Fixed a few bugs and cleaned out a bit.