Optimizated patching system and memory leaks