Code style cleanup, also throw exceptions so calling code can be smarter.