Logging and error handling.
Unnecessary output filtering removed.