Clean up and implement log option.