Fix bug and remove excessive logging