Fix exception caused by checking for a module *after* we use it.