added comments and fixed JS loading issue

memory leak issues removed!!