Refactored log and error.