Made logging to console thread-safe and removed some cruft.