Converted all asserts to exceptions.