move sanity checking code from Storage.c to Sanity.c