Added ability to throw exceptions and different debug levels.