Change assertions to exceptions