Cleaned up exception handling and tests and added global options.