Moving from console to $log for logging. Code clean up.