Fix bug and remove commented code