Fixed Memory leak & some js modifications