implement general refactoring and syntax refinement