Fixed signal handling for Cntrl + c and some other bugs