Shift a few lines around so that stuff gets set only when the relevant modules are definitely loaded