refactor debug loggings.