Accidentally removed sanity checks in previous commit.
This is for the refactor branch