Cleaned up some code, got rid of a nasty call to exit()