Fixed memory leaks from str_replace
Removed unused encode.xml