Refactor some parts