Replaced assertions with exceptions for runtime issues.