Clean up signal handling a bit.
Fix the build.
Fix Peter's comments
Merge pull request #574 from nomis52/master

Clean up signal handling a bit.