Refactoring for 10CS and bug fix #5