Put in sanity checks and appropriate exceptions