Added logging vargs and debug logging functions.
Added error checking and logging.
Fixed an issue with not checking for interrupt sig.