Updated signal handlers and moved forking to lower in the logic