TypeCode Detecting and Refactoring

and structure refactoring