Fix a bug and clean useless function.