refactoring toward a C style codebase