Started to refactor plugin sorting code.