Improvements to sanity checks

Change-Id: I647be1e5e79c5c9fc8fff7a821bf1017606c2558