improved signal handling