Replaced "asserts" with exception-throwing version