[3.0] Fix MemLeak and Apply beautifier in Scanner