Global restructure and refactoring