Fix noise, resource leak and script loading buffer overflow