some big refactor.