Added sighandler for keyboard interrupt, but it's a bit buggy.