Added debug mode and option termination.