Handle signals ... better. not sure if this is all correct