Performance fixes

Updated the code to avoid polluting Global memory. Clearing the view
from DOM once, the todo task is done.