Fixed some problems found through testing.