Ensuring exceptions are thrown when dereferencing