Replaced assertions with exceptions.