Tried to add more runtime sanity checks