refactor the signal handler setup
add server utility functions
use the signal functions added in prev. commit