Added threading. Added signal handling for Ctrl+C