Replace local functions with closures of the project extension