Switched from asserts to exceptions