TODO fix signal handling