Refactoring to change as many functions as static and to improve
source format.