Minor fixes.
Added cleanup logic.
Made it work.