Moved the signal handler registration to the correct location