Fixed logging to console and error detection.