Fix up some bugs, make some code cleaner.