Updated with signal handling.