Added signal handling. Still need cleanup code. A couple more options to be added I think