moved hook registering forward.

Otherwise the hook cannot set up filters before reading files.