Replaced some exceptions with asserts