Fixed logging/debug lines to appropriate place.