Cleaned up a little and fixed some bugs.