Unify duplicated code.
Remove needless code.