fixed some signal handling bugs