Made a few changes to work out some bugs.