Refactor some parts.